package com.xyzwps.server.paimon.model.entity

import com.xyzwps.server.paimon.value.Phone
import com.xyzwps.server.paimon.value.VcodeScene
import org.springframework.data.annotation.Id
import org.springframework.data.relational.core.mapping.Table
import kotlin.time.Instant

@Table("phone_vcode")
data class PhoneVcode(
    @Id
    val id: Long? = null,
    val phone: Phone,
    val scene: VcodeScene,
    val vcode: String,
    val dkey: String,
    val createdAt: Instant,
    val used: Boolean,
    val usedAt: Instant?
) {
    companion object {
        const val PHONE_MAX_LENGTH = COMMON_PHONE_MAX_LENGTH
        const val DKEY_MIN_LENGTH = 12
        const val DKEY_MAX_LENGTH = 60
        const val VCODE_MAX_LENGTH = 10
    }
}
